<!DOCTYPE html>

<html lang="en">
<link rel="stylesheet" href="AmazeUI-2.4.2/assets/css/amazeui.min.css" />
<link href="css/dlstyle.css" rel="stylesheet" type="text/css">
<script src="AmazeUI-2.4.2/assets/js/jquery.min.js"></script>
<script src="AmazeUI-2.4.2/assets/js/amazeui.min.js"></script>
<script type="text/javascript" src="./plugins/vue/dist/vue.min.js"></script>
<script type="text/javascript" src="./plugins/axios/dist/axios.min.js"></script>
<!--引入公共的js-->
<script type="text/javascript" src="./js/common.js"></script>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>

<div id="app"></div>

</body>
<script>
    new Vue({
        el:"#app",
        mounted(){
            var param = getParams();
            console.debug(param);
            //把code发送到后端去
            this.$http.post("/wechat/getToken",param).then(res=>{
                console.debug(res);
                let {message,resultObj,success} = res.data;
                let openid = resultObj.openid;
                if(success&&openid){
                    location.href="http://localhost:8082/binder.html?openid="+openid;
                }else {
                    if(success&&resultObj.token){
                        localStorage.setItem("token",resultObj.token)
                        localStorage.setItem("loginUser",JSON.stringify(resultObj.loginUser))
                        location.href="index.html";
                    }
                }

            })
        }
    })
</script>
</html>